package com.xmu.prcs.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Index;

/**
 * 收藏的植物
 * @author Administrator
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "favorite")
@org.hibernate.annotations.Table(appliesTo = "favorite",
        indexes = {@Index(name = "idxFCT", columnNames = {"collecttime"})})
public class Favorite implements Serializable {

	private Integer idFavorite;
	private String plantName;//植物名
	private Date collectTime;//收藏时间
	private Plant plant;//植物
	
	public Favorite(){
		
	}
	
	public Favorite(String name, Date time){
		this.plantName = name;
		this.collectTime = time;
	}

	@Id
	@GeneratedValue
	@Column(name = "idfavorite", unique = true, nullable = true)
	public Integer getIdFavorite() {
		return idFavorite;
	}

	public void setIdFavorite(Integer idFavorite) {
		this.idFavorite = idFavorite;
	}
	
	@Column(name = "plantname", length = 20)
	public String getPlantName() {
		return plantName;
	}

	public void setPlantName(String plantName) {
		this.plantName = plantName;
	}

	@Column(name = "collecttime")
	public Date getCollectTime() {
		return collectTime;
	}

	public void setCollectTime(Date collectTime) {
		this.collectTime = collectTime;
	}
	
	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "idplant", nullable = true)
	public Plant getPlant() {
		return plant;
	}

	public void setPlant(Plant plant) {
		this.plant = plant;
	}

	
}
